

package cn.shengchao.controler.user;

import cn.shengchao.util.helper.LoginHelper;
import cn.shengchao.examstart.user.ohs.local.appservices.RealPersonAppService;
import cn.shengchao.examstart.user.ohs.local.messages.UserRealPersonDto;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Tag(name = "实人认证")
@Slf4j
@RestController
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/realPerson")
public class RealPersonController {

    @Autowired
    private RealPersonAppService realPersonService;

    @PostMapping
    public void realPerson(@RequestBody UserRealPersonDto userRealPerson) throws IOException {
        Long uid = LoginHelper.getUserId();
        realPersonService.save(userRealPerson, uid);
    }

    @GetMapping
    public UserRealPersonDto getRealPerson() {
        Long uid = LoginHelper.getUserId();
        return realPersonService.getRealPerson(uid);
    }

}
